// 全局混入一些常用的属性跟方法
import { baseUrl, cosUrl } from '../env.config'
import defaultAvatar from 'images/common/default_avatar.png'
export default {
  data() {
    return {
      _baseUrl: baseUrl,
      _cosUrl: cosUrl,
      _defaultAvatar: defaultAvatar,
    }
  },
  created() {
    uni._baseUrl = this._baseUrl
    uni._cosUrl = this._cosUrl
    uni._toPage = this._toPage
    uni.callPhone = this._callPhone
  },
  methods: {
    _toPage(url, type) {
      if (type === 'tabbar') {
        uni.switchTab({ url })
      } else {
        if (url) {
          uni.navigateTo({ url })
        } else {
          uni.navigateBack()
        }
      }
    },
    _callPhone(tel) {
      uni.makePhoneCall({
        phoneNumber: tel,
      })
    },
  },
}
